import { Controller, Post, Body } from '@nestjs/common';
import { ApiKeyService } from './api-key.service';

@Controller('api-keys')
export class ApiKeyController {
  constructor(private apiKeyService: ApiKeyService) { }

  @Post('generate')
  async generate(@Body() body: { userId: string; allowedModules: string[]; totalQuota: number }) {
    const { userId, allowedModules, totalQuota } = body;
    const result = await this.apiKeyService.generateApiKeyPair(userId, allowedModules, totalQuota);
    return {
      message: 'API key pair generated (store the secret securely - it will not be shown again)',
      ...result,
    };
  }
}